import {ref, computed, reactive} from 'vue'
import {defineStore} from 'pinia'


export const staticAssertsStore = defineStore(
    "staticAssertsStore",
    () => {
        const assertCache = reactive({})

        function addInfo({key, id, data}) {
            if (assertCache[key] === undefined) {
                assertCache[key] = {}
            }
            assertCache[key][id] = data;
        }

        //同步获取数据
        function getAssertSync({key, id}) {
            if (assertCache[key] === undefined) {
                assertCache[key] = {}
            }

            return assertCache[key][id]
        }

        //异步获取数据
        function getAssertASync({key, id}) {
            return new Promise((resolve, reject) => {
                if (assertCache[key] === undefined) {
                    assertCache[key] = {}
                }
                resolve(assertCache[key][id])
            })
        }

        return {
            assertCache,
            addInfo,
            getAssertSync,
            getAssertASync
        }
    }
);


export const item_store = "item_store";
export const champion_store = "champion_store";
export const queue_store = "queue_store";
export const spell_store = "spell_store";
export const perk_style_store = "perk_style_store";
export const perks_store = "perks_store";
export const map_store = "map_store";

